<?
/*error_reporting(E_ALL);
ini_set("display_errors", 1); */
function curPageURL() {
 $pageURL = 'http';
 if ($_SERVER["HTTPS"] == "on") {$pageURL .= "s";}
 $pageURL .= "://";
 if ($_SERVER["SERVER_PORT"] != "80") {
  $pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
 } else {
  $pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
 }
 return $pageURL;
}

function rand_string( $length ) {
	$chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";	

	$size = strlen( $chars );
	for( $i = 0; $i < $length; $i++ ) {
		$str .= $chars[ rand( 0, $size - 1 ) ];
	}

	return $str;
}

$linkCurrent =  substr(curPageURL(),0,-12);
// Call the nuSOAP library
$joined = time();
$email = 'nganly66@icsc.vn';
$password = '123456';
$password_salt = rand_string(3);
$full_name = 'Ngan Ly A';

$url = $linkCurrent.'index.php?do=/user/getpassword&pass='.$password.'&salt='.$password_salt;
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HEADER, false);
$passwordend = curl_exec($curl);
curl_close($curl);
require_once('nusoap/nusoap.php');
// Create the client instance
$client = new nusoap_client($linkCurrent.'ws.php?wsdl', true);
$client->use_curl=true;

$last_ip_address = $_SERVER['REMOTE_ADDR'];
try { 
$result = $client->call('registerUser', array('email' => $email, 'password' => $passwordend, 'password_salt'=> $password_salt, 'full_name' => $full_name, 'joined' => $joined, 'last_ip_address' => $last_ip_address));
}catch (Exception $exception){
} 
		
// Display the result
print_r($result);
// Check for a fault
if ($client->fault) {
	echo '<h2>Fault</h2><pre>';
	print_r($result);
	echo '</pre>';
} else {
	// Check for errors
	$err = $client->getError();
	if ($err) {
		// Display the error
		echo '<h2>Error</h2><pre>' . $err . '</pre>';
	} else {
		// Display the result
		echo '<h2>Result</h2><pre>';
		print_r($result);
		echo '</pre>';
	}
}
// Display the request and response
echo '<h2>Request</h2>';
echo '<pre>' . htmlspecialchars($client->request, ENT_QUOTES) . '</pre>';
echo '<h2>Response</h2>';
echo '<pre>' . htmlspecialchars($client->response, ENT_QUOTES) . '</pre>';
?>